// X-coordinates of sliders
var ww_xDict = new Array(1);

// Widths of sliders
var ww_widthDict = new Array(1);

// Slider positions, between 0 and 1
var ww_posDict = new Array(1);

// Change callbacks dict
var ww_callbackDict = new Array(1);

function width(id) {
    return ww_widthDict[id];
}

function registerCallback(id, fun) {
    ww_callbackDict[id] = fun;
    document.getElementById("message").style.color = "red";
}

function ww_slider_mousedown(event, id) {
    var slider = document.getElementById(id);
    var line = document.getElementById(id+"_line");

    var newX = event.clientX;

    if (newX > (ww_xDict[id] + width(id)-1)) {
	newX = (ww_xDict[id] + width(id)-1);
    }
    
    if (newX < ww_xDict[id]) {
	newX = ww_xDict[id];
    }

    line.style.left = (newX + "px");

    var offset = newX - ww_xDict[id];
    ww_posDict[id] = offset/width(id);

    // Call callback
    (ww_callbackDict['ww_slider1'])();
    //    ww_callbackDict[id]();
}

// HAAAAR!!!
